import Mock from 'mockjs';
const Random = Mock.Random;

Mock.mock(RegExp('/app/banner/page'), 'get', (req) => {
    const { pageSize, pageNumber } = req.body;
    return Mock.mock({
        statusCode: 200,
        message: '查询成功',
        data: {
            total: 200,
            pageSize,
            pageNumber,
            ['list|' + pageNumber]: [
                {
                    id: '@id',
                    name: '@cname',
                    url: Random.image('200x100')
                }
            ]
        }
    })
});

Mock.mock(RegExp('/app/banner/list'), 'get', () => {
    return Mock.mock({
        statusCode: 200,
        message: '查询成功',
        'data|5': [
            {
                id: '@id',
                name: '@cname',
                imageUrl: Random.image('750x450', '#00CC4C', '#FFF', 'Mock.js')
            },
        ]
    })
});

Mock.mock(RegExp('/app/banner/info'), 'get', () => {
    return {
        statusCode: 200,
        message: '查询成功',
        data: {
            id: '@id',
            name: '@cname'
        }
    }
});

Mock.mock(RegExp('/app/banner/add'), 'post', () => {
    return {
        statusCode: 200,
        message: '新增成功',
        data: {}
    }
});

Mock.mock(RegExp('/app/banner/add'), 'post', () => {
    return {
        statusCode: 200,
        message: '保存成功',
        data: {}
    }
});

Mock.mock(RegExp('/app/banner/update'), 'post', () => {
    return {
        statusCode: 200,
        message: '更新成功',
        data: {}
    }
});

Mock.mock(RegExp('/app/banner/delete'), 'post', () => {
    return {
        statusCode: 200,
        message: '删除成功',
        data: {}
    }
});
